/*
 * Generated file. 
 * 
 * Mobile_005fhome.java
 */
package xsp;

import com.ibm.xsp.page.compiled.AbstractCompiledPage;
import com.ibm.xsp.page.compiled.AbstractCompiledPageDispatcher;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import com.ibm.xsp.page.compiled.NoSuchComponentException;
import com.ibm.xsp.page.compiled.PageExpressionEvaluator;
import java.lang.String;
import java.lang.Object;
import java.lang.Integer;
import javax.faces.el.MethodBinding;
import com.ibm.xsp.component.FacesPageProvider;
import com.ibm.xsp.component.UIViewRootEx2;
import com.ibm.xsp.extlib.component.mobile.UIDMHeading;
import javax.faces.el.ValueBinding;
import com.ibm.xsp.extlib.component.mobile.UIToolBarButton;
import com.ibm.xsp.extlib.component.outline.UIOutlineGeneric;
import com.ibm.xsp.extlib.tree.complex.ComplexLeafTreeNode;

@SuppressWarnings("all")
public class Mobile_005fhome extends AbstractCompiledPageDispatcher{

    private static final String[][] s_libraryVersions = new String[][]{
        {"com.ibm.xsp.extlib.library", "8.5.32006"},  // version of "xe:toolBarButton"
    };
    
    public Mobile_005fhome() {
        super("3.0");
    }

    protected String[][] getLibraryTagVersions() {
        return s_libraryVersions;
    }

    protected AbstractCompiledPage createPage(int pageIndex) {
        return new Mobile_005fhomePage();
    }
    
    protected boolean isCustomControl() {
        return true;
    }

    public static class Mobile_005fhomePage extends AbstractCompiledPage {
        
        private static final ComponentInfo[] s_infos = new ComponentInfo[]{
            ComponentInfo.EMPTY_NORMAL, // 0 "link1"
            new ComponentInfo(false, null, // 1 "djxmheading0"
              new Object[][]{
                new Object[]{"actionFacet", Integer.valueOf(0)},
              } ),
            ComponentInfo.EMPTY_NORMAL, // 2 outline
            new ComponentInfo(false, new int[]{1, 2}), // 3 view
        };
        
        public Mobile_005fhomePage() {
            super(3, s_infos );
        }
        
        public int getComponentForId(String id) throws NoSuchComponentException { 
            if( "djxmheading0".equals(id) )
                return 1;
            if( "link1".equals(id) )
                return 0;
            return -1;
        }
        
        public UIComponent createComponent(int id, FacesContext context,
                UIComponent parent, PageExpressionEvaluator evaluator)
                throws NoSuchComponentException { 
            switch (id) {
            case 3:
                return createView(context, parent, evaluator);
            case 1:
                return createDjxmheading0(context, parent, evaluator);
            case 0:
                return createLink1(context, parent, evaluator);
            case 2:
                return createOutline(context, parent, evaluator);
            }
            throw new NoSuchComponentException(id);
        }
        
        protected void initIncluderAsRoot(FacesContext context,
                PageExpressionEvaluator evaluator, UIComponent root) {
            String sourceId = "/xp:view[1]/xp:this.beforePageLoad[1]/text()";
            MethodBinding beforePageLoad = evaluator.createMethodBinding(root,
                    "#{javascript:\n\t\t\tvar _request = facesContext.getExternalContext().getRequest();\n\t\t\tvar _cookies = _request.getHeader(\"Cookie\");\n\t\t\t// See here what cookies we need to analyze:\n\t\t\t// http://www-01.ibm.com/support/docview.wss?uid=swg27003558\n\t\t\t// Also - for Domino 8.5.4 you could have just LtpaToken2 SSO\n\t\t\tvar _isSessionAuth = (@Contains(_cookies, \"DomAuthSessId\") === 1 || \n\t\t\t@Contains(_cookies, \"LtpaToken\") === 1 || \n\t\t\t@Contains(_cookies, \"LtpaToken2\") === 1) ? true : false;\n\t\t\tviewScope.put(\"isSessionAuth\", _isSessionAuth);\n\t\t}",
                    null,null, sourceId);
            FacesPageProvider asPageProvider = root instanceof FacesPageProvider ?
                    (FacesPageProvider) root : null;
            if( null != asPageProvider ){
                asPageProvider.setBeforePageLoad(beforePageLoad);
            }
        }

        private UIComponent createView(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            UIViewRootEx2 result = new UIViewRootEx2();
            initViewRoot(result);
            String sourceId = "/xp:view[1]/xp:this.beforePageLoad[1]/text()";
            MethodBinding beforePageLoad = evaluator.createMethodBinding(result,
                    "#{javascript:\n\t\t\tvar _request = facesContext.getExternalContext().getRequest();\n\t\t\tvar _cookies = _request.getHeader(\"Cookie\");\n\t\t\t// See here what cookies we need to analyze:\n\t\t\t// http://www-01.ibm.com/support/docview.wss?uid=swg27003558\n\t\t\t// Also - for Domino 8.5.4 you could have just LtpaToken2 SSO\n\t\t\tvar _isSessionAuth = (@Contains(_cookies, \"DomAuthSessId\") === 1 || \n\t\t\t@Contains(_cookies, \"LtpaToken\") === 1 || \n\t\t\t@Contains(_cookies, \"LtpaToken2\") === 1) ? true : false;\n\t\t\tviewScope.put(\"isSessionAuth\", _isSessionAuth);\n\t\t}",
                    null,null, sourceId);
            result.setBeforePageLoad(beforePageLoad);
            return result;
        }

        private UIComponent createDjxmheading0(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            UIDMHeading result = new UIDMHeading();
            String sourceId = "djxmHeading0/xe:this.label[1]/text()";
            String labelExpr = "#{javascript:\n\t\t\t@DbTitle();\n\t\t}";
            ValueBinding label = evaluator.createValueBinding(result, labelExpr, sourceId,String.class);
            result.setValueBinding("label", label);
            result.setStyleClass("mblLoginText");
            setId(result, "djxmHeading0");
            return result;
        }

        private UIComponent createLink1(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            UIToolBarButton result = new UIToolBarButton();
            String sourceId = "link1/xp:this.label[1]/text()";
            String labelExpr = "#{javascript:\n\t\t\t\t\tif(userBean.canonicalName === \'Anonymous\')\n\t\t\t\t\t{\n\t\t\t\t\t\treturn res.getString(\"banner.login\");\n\t\t\t\t\t}\n\t\t\t\t\telse if(viewScope.get(\"isSessionAuth\") === true)\n\t\t\t\t\t{\n\t\t\t\t\t\treturn res.getString(\"banner.logout\");\n\t\t\t\t\t}\n\t\t\t\t}";
            ValueBinding label = evaluator.createValueBinding(result, labelExpr, sourceId,String.class);
            result.setValueBinding("label", label);
            String sourceId2 = "link1/xp:this.rendered[1]/text()";
            String renderedExpr = "#{javascript:\n\t\t\t\t\t\tif(view.isRenderingPhase()){\n\t\t\t\t\t\t\tif((userBean.canonicalName !== \"Anonymous\") && (viewScope.get(\"isSessionAuth\") === false)){\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}";
            ValueBinding rendered = evaluator.createValueBinding(result, renderedExpr, sourceId2,boolean.class);
            result.setValueBinding("rendered", rendered);
            String sourceId3 = "link1/xp:this.href[1]/text()";
            String hrefExpr = "#{javascript:\n\t\t\t\t\t\tif(userBean.canonicalName === \'Anonymous\')\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treturn facesContext.getExternalContext().getRequestContextPath() + \"?opendatabase&login\";\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treturn facesContext.getExternalContext().getRequestContextPath() + \"?logout\";\n\t\t\t\t\t\t}\n\t\t\t\t\t}";
            ValueBinding href = evaluator.createValueBinding(result, hrefExpr, sourceId3,String.class);
            result.setValueBinding("href", href);
            setId(result, "link1");
            return result;
        }

        private UIComponent createOutline(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            UIOutlineGeneric result = new UIOutlineGeneric();
            ComplexLeafTreeNode treeNodes = new ComplexLeafTreeNode();
            treeNodes.setComponent(result);
            treeNodes.setLabel("All Documents");
            treeNodes.setHref("#allDocs");
            result.addNode(treeNodes);
            ComplexLeafTreeNode treeNodes2 = new ComplexLeafTreeNode();
            treeNodes2.setComponent(result);
            treeNodes2.setLabel("Most Recent");
            treeNodes2.setHref("#mostRecent");
            result.addNode(treeNodes2);
            ComplexLeafTreeNode treeNodes3 = new ComplexLeafTreeNode();
            treeNodes3.setComponent(result);
            treeNodes3.setLabel("By Author");
            treeNodes3.setHref("#docsByAuthor");
            result.addNode(treeNodes3);
            ComplexLeafTreeNode treeNodes4 = new ComplexLeafTreeNode();
            treeNodes4.setComponent(result);
            treeNodes4.setLabel("By Tag");
            treeNodes4.setHref("#tags");
            result.addNode(treeNodes4);
            ComplexLeafTreeNode treeNodes5 = new ComplexLeafTreeNode();
            treeNodes5.setComponent(result);
            treeNodes5.setLabel("My Documents");
            treeNodes5.setHref("#myDocs");
            result.addNode(treeNodes5);
            ComplexLeafTreeNode treeNodes6 = new ComplexLeafTreeNode();
            treeNodes6.setComponent(result);
            treeNodes6.setStyle("overflow: hidden;");
            String sourceId = "/xp:view[1]/xe:outline[1]/xe:this.treeNodes[1]/xe:basicLeafNode[6]/@label";
            String labelExpr = "#{javascript: I18n.format(res.getString(\'my.profile\'), userBean.commonName)}";
            ValueBinding label = evaluator.createValueBinding(result, labelExpr, sourceId,String.class);
            treeNodes6.setValueBinding("label", label);
            String sourceId2 = "/xp:view[1]/xe:outline[1]/xe:this.treeNodes[1]/xe:basicLeafNode[6]/xp:this.rendered[1]/text()";
            String renderedExpr = "#{javascript:\n\t\t\t\t\tuserBean.canonicalName !== \"Anonymous\";\n\t\t\t\t}";
            ValueBinding rendered = evaluator.createValueBinding(result, renderedExpr, sourceId2,boolean.class);
            treeNodes6.setValueBinding("rendered", rendered);
            treeNodes6.setHref("#profile");
            result.addNode(treeNodes6);
            return result;
        }

    }
}
